import sys

from pip import main
sys.path.append('F:\\python36\\Lib\\site-packages')

import time,threading
from PIL import ImageGrab
from cv2 import *
import numpy as np
from pynput import keyboard

import deserialization
import getDataStream

continueFlag=True

screen = ImageGrab.grab()
width, high = screen.size
fourcc = VideoWriter_fourcc('X', 'V', 'I', 'D')
video = VideoWriter('./video.avi', fourcc, 15, (width, high))
    
def resolveByteData(bdata):
    ims=deserialization.deserialize(bdata)
    for im in ims:
        imm = cvtColor(np.array(im), COLOR_RGB2BGR) # 转为opencv的BGR模式
        video.write(imm)  #写入
    

def makeVideo():
    video.release()
    
def getDateStream():
    return 


def do():
    data=getDataStream.getFromRedis("xiaohao")
    
    resolveByteData(data)
    makeVideo()
    
if __name__=="__main__":
    do()